import request from '@/utils/request'
import qs from 'qs'

/**
 * 获取列表
 * @param limit
 * @param offset
 */
export function page(limit, offset) {
  return request({
    url: '/system/baseWordTemplate/getPage',
    method: 'post',
    data: qs.stringify({
      limit,
      offset
    })
  })
}

/**
 * 获取详情
 * @param id
 */
export function getInfo(id) {
  return request({
    url: '/system/baseWordTemplate/getInfo',
    method: 'post',
    data: qs.stringify({
      id
    })
  })
}

export function getWordTemplateAll(id) {
  return request({
    url: '/system/baseWordTemplate/getAll',
    method: 'post',
    data: qs.stringify({
      id
    })
  })
}

/**
 * 删除
 * @param id
 */
export function delInfo(id) {
  return request({
    url: '/system/baseWordTemplate/del',
    method: 'post',
    data: qs.stringify({
      id
    })
  })
}

/**
 * 生成文件
 * @param id
 * @param caseId
 */
export function makefile(id, caseId) {
  return request({
    url: '/system/baseWordTemplate/makefile',
    method: 'post',
    data: qs.stringify({
      id, caseId
    })
  })
}

/**
 * 批量生成文件
 * @param id
 * @param caseId
 */
export function makefileBatch(id, name, judgeName, caseNum, caseTypeId, caseState, caseNode, caseDeptId, bankId, attorneyUserId, tabNameSuffix, courtId, type, stTime, endTime) {
  return request({
    url: '/system/baseWordTemplate/makefileBatch',
    method: 'post',
    data: qs.stringify({
      id,
      name,
      judgeName,
      caseNum,
      caseTypeId,
      caseState,
      caseNode,
      caseDeptId,
      bankId,
      attorneyUserId,
      tabNameSuffix,
      courtId,
      type,
      stTime,
      endTime
    })
  })
}

/**
 * 批量生成文件2
 * @param id
 * @param caseId
 */
export function makefileBatch2(id, ids) {
  return request({
    url: '/system/baseWordTemplate/makefileBatch2',
    method: 'post',
    data: qs.stringify({
      id,
      ids
    })
  })
}

export function checkFile(id, ids) {
  return request({
    url: '/system/baseWordTemplate/checkFile',
    method: 'post',
    data: qs.stringify({
      id,
      ids
    })
  })
}

/**
 * 新增或编辑
 * @param id
 * @param name
 * @param state
 */
export function addOrEdit(id, name, bankId, fileUrl, fileType, fileModule) {
  return request({
    url: '/system/baseWordTemplate/addOrEdit',
    method: 'post',
    data: qs.stringify({
      id, name, bankId, fileUrl, fileType, fileModule
    })
  })
}

/**
 * 文件转PDF或者图片下载
 * @param id
 * @param name
 * @param state
 */
export function dow(fileUrl) {
  return request({
    url: '/system/template/dow',
    method: 'post',
    data: qs.stringify({
      fileUrl
    })
  })
}
